package mobi.greenplate.theweb.config;

import mobi.greenplate.theweb.persistence.AppEngineEntityManagerFactory;
import javax.persistence.EntityManagerFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.orm.jpa.JpaTransactionManager;

/**
 *
 * @author Dimitar Makariev
 */
@Configuration
public class AppConfig {
    
    @Bean
    EntityManagerFactory entityManagerFactory() {       
        return AppEngineEntityManagerFactory.entityManagerFactory();
    }
    
    @Bean
    JpaTransactionManager transactionManager() {
        final JpaTransactionManager transactionManager = new JpaTransactionManager();
        transactionManager.setEntityManagerFactory(entityManagerFactory());
        return transactionManager;
    } 
}
